In [1]:
import dmdd
import numpy as np
%matplotlib inline


WARNING:root:pymultinest not imported!
WARNING:root:DMDD_MAIN_PATH environment variable not defined, defaulting to:   ~/.dmdd

In [2]:
reload(dmdd)


Out[2]:
<module 'dmdd' from 'dmdd/__init__.pyc'>

This cell demonstrates that dRdQ_AM has the same value as dRdQ at day 0 and day 365, when the v_lag is = 220.


In [3]:
print dmdd.dRdQ_AM(Q = [100.], sigma_si = 75.5)
print dmdd.rate_UV.dRdQ(Q = np.asarray([100.]), sigma_si = 75.5)
print dmdd.dRdQ_AM(Q = [100.], sigma_si = 75.5, time = 365)


[  2.80527965e-17]
[  2.80527965e-17]
[  2.80527965e-17]

This cell demonstates the rate_UV.dRdQ can recieve multiple Qs and return them as an array. The following cell shows the same thing, but for dRdQ_AM.


In [ ]:
dmdd.rate_UV.dRdQ(Q = np.array([50., 60., 70., 80., 90., 100.]), sigma_si = 75.5)

# demonstrats that rate_UV.dRdQ can take multiple Q's

In [4]:
dmdd.dRdQ_AM(Q = [10., 30., 50., 100.], sigma_si = 75.5, time = 0)
# demonstrates that dRdQ_AM can take multiple Q's as a list


Out[4]:
array([  3.36242431e-10,   3.99546567e-11,   3.41365358e-12,
         2.80527965e-17])

This cell is showing the relative progression of rate over various times for fixed parameters.


In [5]:
print dmdd.dRdQ_AM(sigma_si = 75.5, time = 50)
print dmdd.dRdQ_AM(sigma_si = 75.5, time = 100)
print dmdd.dRdQ_AM(sigma_si = 75.5, time = 150)
print dmdd.dRdQ_AM(sigma_si = 75.5, time = 200)
print dmdd.dRdQ_AM(sigma_si = 75.5, time = 250)
print dmdd.dRdQ_AM(sigma_si = 75.5, time = 300)
print dmdd.dRdQ_AM(sigma_si = 75.5, time = 350)


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-c3e28c199971> in <module>()
----> 1 print dmdd.dRdQ_AM(sigma_si = 75.5, time = 50)
      2 print dmdd.dRdQ_AM(sigma_si = 75.5, time = 100)
      3 print dmdd.dRdQ_AM(sigma_si = 75.5, time = 150)
      4 print dmdd.dRdQ_AM(sigma_si = 75.5, time = 200)
      5 print dmdd.dRdQ_AM(sigma_si = 75.5, time = 250)

/Users/katelynneese/dmddACT/dmdd/dmdd.py in dRdQ_AM(mass, sigma_si, sigma_anapole, Q, time, bins, element, vlag_mean, v_amplitude)
     80     #print type(v_lag) #vlag must be a number not an array
     81 
---> 82     rate_QT = rate_UV.dRdQ(Q = energy, v_lag = v_lag, mass = mass, sigma_si = sigma_si, sigma_anapole = sigma_anapole, element = element)
     83 
     84     "Return a 1D array with the rate based on the time and energy given"

rate_UV.pyx in rate_UV.dRdQ (dmdd/rate_UV.c:14430)()

ValueError: Buffer has wrong number of dimensions (expected 1, got 0)

Demonstration of integral function


In [4]:
dmdd.integral(1., 100., 0., 365., sigma_si = 75.5)


Out[4]:
2.9231845333250124e-06

Testing integral function for a known integral with an exact value of 1/6 .


In [3]:
def funct1(Q,time, sigma_si, sigma_anapole, mass, element, v_amplitude):
    return (Q**2)*(time)
#have to define like this due to the way integral is defined, but still returns correct answer

In [4]:
dmdd.integral(0, 1, 0, 1, function = funct1)


Out[4]:
0.16675008341675007

Model and experiment to be used in simulations


In [3]:
# shortcut for scattering models corresponding to rates coded in rate_UV:
anapole_model = dmdd.UV_Model('Anapole', ['mass','sigma_anapole'])
SI_model = dmdd.UV_Model('SI', ['mass','sigma_si'])

print 'model: {}, parameters: {}.'.format(anapole_model.name, anapole_model.param_names)
print 'model: {}, parameters: {}.'.format(SI_model.name, SI_model.param_names)


model: Anapole, parameters: ['mass', 'sigma_anapole'].
model: SI, parameters: ['mass', 'sigma_si'].

In [4]:
# intialize an Experiment with XENON target, to be passed to Simulation_AM:
xe = dmdd.Experiment('1xe', 'xenon', 5, 150, 1000, dmdd.eff.efficiency_unit, energy_resolution=True)

Attempting to run Simulation_AM


In [8]:
xe = dmdd.Simulation_AM('AM_xenon', xe, SI_model, 
                        {'mass':50.,'sigma_si':75.5}, Qmin = np.asarray([5.]), 
                        Qmax = np.asarray([150.]), 
                        Tmin = 0, Tmax = 365, sigma_si = 75.5, 
                        element = 'xenon', force_sim = True)


Existing simulation does not match current parameters.  Forcing simulation.


simulated: 180 events (expected 169).
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-8-1d9b95e61ab7> in <module>()
      3                         Qmax = np.asarray([150.]),
      4                         Tmin = 0, Tmax = 365, sigma_si = 75.5,
----> 5                         element = 'xenon', force_sim = True)
      6 
      7 

/Users/katelynneese/dmddACT/dmdd/dmdd.py in __init__(self, name, experiment, model, parvals, Qmin, Qmax, element, sigma_si, sigma_anapole, mass, v_amplitude, Tmin, Tmax, path, force_sim, asimov, nbins_asimov, plot_nbins, plot_theory, silent)
   1107 
   1108         if force_sim or (not os.path.exists(self.plotfile)):
-> 1109             self.plot_data(plot_nbins=plot_nbins, plot_theory=plot_theory, save_plot=True)
   1110         else:
   1111             if not self.silent:

/Users/katelynneese/dmddACT/dmdd/dmdd.py in plot_data(self, plot_nbins, plot_theory, save_plot, make_plot, return_plot_items)
   1235            # plt.legend(prop={'size':20},numpoints=1)
   1236             if save_plot:
-> 1237                 plt.savefig(self.plotfile, bbox_extra_artists=[xlabel, ylabel], bbox_inches='tight')
   1238 
   1239 

//anaconda/lib/python2.7/site-packages/matplotlib/pyplot.pyc in savefig(*args, **kwargs)
    575 def savefig(*args, **kwargs):
    576     fig = gcf()
--> 577     res = fig.savefig(*args, **kwargs)
    578     draw()   # need this if 'transparent=True' to reset colors
    579     return res

//anaconda/lib/python2.7/site-packages/matplotlib/figure.pyc in savefig(self, *args, **kwargs)
   1474             self.set_frameon(frameon)
   1475 
-> 1476         self.canvas.print_figure(*args, **kwargs)
   1477 
   1478         if frameon:

//anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
   2166                 bbox_filtered = []
   2167                 for a in bbox_artists:
-> 2168                     bbox = a.get_window_extent(renderer)
   2169                     if a.get_clip_on():
   2170                         clip_box = a.get_clip_box()

AttributeError: 'str' object has no attribute 'get_window_extent'

In [9]:
xe = dmdd.Simulation_AM('AM_xenon', xe, anapole_model, 
                        {'mass':50.,'sigma_anapole':44.25}, Qmin = np.asarray([5.]), 
                        Qmax = np.asarray([150.]), 
                        Tmin = 0, Tmax = 365, sigma_anapole = 44.25, 
                        element = 'xenon', force_sim = True)


Simulation data and/or pickle file does not exist. Forcing simulation.


simulated: 171 events (expected 168).
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-9-44c98d9d78ec> in <module>()
      3                         Qmax = np.asarray([150.]),
      4                         Tmin = 0, Tmax = 365, sigma_anapole = 44.25,
----> 5                         element = 'xenon', force_sim = True)
      6 
      7 

/Users/katelynneese/dmddACT/dmdd/dmdd.py in __init__(self, name, experiment, model, parvals, Qmin, Qmax, element, sigma_si, sigma_anapole, mass, v_amplitude, Tmin, Tmax, path, force_sim, asimov, nbins_asimov, plot_nbins, plot_theory, silent)
   1107 
   1108         if force_sim or (not os.path.exists(self.plotfile)):
-> 1109             self.plot_data(plot_nbins=plot_nbins, plot_theory=plot_theory, save_plot=True)
   1110         else:
   1111             if not self.silent:

/Users/katelynneese/dmddACT/dmdd/dmdd.py in plot_data(self, plot_nbins, plot_theory, save_plot, make_plot, return_plot_items)
   1235             plt.legend(prop={'size':20},numpoints=1)
   1236             if save_plot:
-> 1237                 plt.savefig(self.plotfile, bbox_extra_artists=[xlabel, ylabel], bbox_inches='tight')
   1238 
   1239 

//anaconda/lib/python2.7/site-packages/matplotlib/pyplot.pyc in savefig(*args, **kwargs)
    575 def savefig(*args, **kwargs):
    576     fig = gcf()
--> 577     res = fig.savefig(*args, **kwargs)
    578     draw()   # need this if 'transparent=True' to reset colors
    579     return res

//anaconda/lib/python2.7/site-packages/matplotlib/figure.pyc in savefig(self, *args, **kwargs)
   1474             self.set_frameon(frameon)
   1475 
-> 1476         self.canvas.print_figure(*args, **kwargs)
   1477 
   1478         if frameon:

//anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
   2166                 bbox_filtered = []
   2167                 for a in bbox_artists:
-> 2168                     bbox = a.get_window_extent(renderer)
   2169                     if a.get_clip_on():
   2170                         clip_box = a.get_clip_box()

AttributeError: 'str' object has no attribute 'get_window_extent'

In [ ]: